package com.buanalintas.sandals.pos.pricebuy;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.bynga.formatter.MoneyFormatter;
import com.buanalintas.sandals.pos.entities.PosMasterPriceBuy;

public class PriceBuy extends Page {

    private Field priceBuyId;
    private Field priceBuyValue;

    public PriceBuy() {
        setTheClass(PosMasterPriceBuy.class);

        priceBuyId = new Field();
        priceBuyId.setName("priceBuyId");
        priceBuyId.setCaption("id");
        priceBuyId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        priceBuyId.setInputProperties(" size=\"20\"");
        getFields().add(priceBuyId);

        priceBuyValue = new Field();
        priceBuyValue.setName("priceBuyValue");
        priceBuyValue.setCaption("price sell");
        priceBuyValue.setListProperties(" align=\"right\" width=\"95%\" nowrap");
        priceBuyValue.setInputProperties(" size=\"30\" ");
        priceBuyValue.setFormater(MoneyFormatter.getInstance());
        priceBuyValue.setRequired(true);
        getFields().add(priceBuyValue);
        
        fillFields();

        getFieldsAdd().remove(priceBuyId);
        getFieldsEdit().remove(priceBuyId);
        getFieldsList().remove(priceBuyId);
        
        setExportList(getClass().getResourceAsStream("PriceBuyList.jasper"));
        setExport(getClass().getResourceAsStream("PriceBuy.jasper"));
        getController().setOrder(priceBuyValue);
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Price Buy"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }
}
